﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Data;

namespace XgPushTest
{
    public class DbDao
    {
        /// <summary>
        /// 获取app配置
        /// </summary>
        /// <returns></returns>
        public AppPushSettingInfo GetAppSetting(string appType)
        {
            AppPushSettingInfo model = new AppPushSettingInfo();
            string sql = "SELECT [appId],[access_id],[secret_key],[appType] FROM [dbo].[T_AppPushSettingInfo] where [appType]=@appType";
            System.Data.SqlClient.SqlParameter parame = new System.Data.SqlClient.SqlParameter("@appType", appType);
            DataTable dt = SQLHepler.GetDataSet(sql,parame).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                var item = dt.Rows[0];
                model.AppId = item["appId"].GetType() == typeof(System.DBNull) ? "" : Convert.ToString(item["appId"]);
                model.Access_id = item["access_id"].GetType() == typeof(System.DBNull) ? "" : Convert.ToString(item["access_id"]);
                model.Secret_key = item["secret_key"].GetType() == typeof(System.DBNull) ? "" : Convert.ToString(item["secret_key"]);
            }
            return model;
        }


    }
}
